package com.itheima.test.service.impl;

import com.itheima.test.entity.User;
import com.itheima.test.mapper.UserClassMapper;
import com.itheima.test.mapper.UserDepartMapper;
import com.itheima.test.mapper.UserMapper;
import com.itheima.test.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.test.vo.UserClass;
import com.itheima.test.vo.UserDepart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author itheima
 * @since 2021-03-23
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private UserClassMapper userClassMapper;
    @Autowired
    private UserDepartMapper userDepartMapper;

    @Override
    public void addUser(User user) {
        System.out.println(user.getUsername());
//      插入学生信息
        userMapper.insert(user);
//      插入班级
        UserClass uc = new UserClass();
        uc.setUsername(user.getUsername());
        uc.setCid(1);
        userClassMapper.insert(uc);
//      插入院系
        UserDepart ud = new UserDepart();
        ud.setUsername(user.getUsername());
        ud.setDid(1);
        userDepartMapper.insert(ud);
    }
}
